<form class="layui-form" action="{:url()}" method="post" id="editForm">
   {:FormExt::input('订单号', 'client_ordernum', '', '请输入订单号', 'required', 'lay-verify="required"')}
    {:FormExt::select('核价类型', 'type', '',$typeMap,'','','lay-verify="required" ')}
    {:FormExt::select('物料', 'mid', '',[],'','','lay-verify="required" ')}

    <div class="pop-bottom-bar">
    	<input type="hidden" class="field-id" name="id">
        <button type="submit" class="layui-btn layui-btn-normal" lay-submit="" lay-filter="formSubmit" hisi-data="{pop: true, refresh: true}">提交保存</button>
        <a href="javascript:parent.layui.layer.closeAll();" class="layui-btn layui-btn-primary ml10">取消</a>
    </div>
</form>

{include file="system@block/layui" /}
    
<script>
    var formData = {:json_encode($formData)};
    layui.use(['form', 'func'], function() {
        var $ = layui.jquery, form = layui.form;
        layui.func.assign(formData);
        //输入框的值改变时触发
        $('[name="client_ordernum"]').on("input",function(e){
            //获取input输入的值
            console.log(e.delegateTarget.value);
            $.ajax({
                type: "POST",
                url: "{:url('mp/CostCheck/selectMaterial')}",
                data: {client_ordernum:e.delegateTarget.value} ,
                dataType:"json",
                success: function(res){
                    if (res.code == 1) {
                        var option = '';
                        $.each( res.data, function(i, n){
                            option += '<option value="'+n.mid+'">'+n.name+'</option>';
                        });
                        $("select[name=mid] option").remove();
                        $('select[name=mid]').append(option);
                        form.render();
                    } else {
                        // layer.msg(res.msg, {icon: 2,anim: 6});
                    }
                }
            });
        });
    });
</script>